home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 2 / United Public Domain Gold 2.iso / utilities / pu619.dms / pu619.adf / Utilities / TASKE.LHA / Source / utility.c < prev    next >
C/C++ Source or Header  |  1993-08-26  |  3KB  |  93 lines

  1. /*
  2.  * Copyright (c) 1993 Michael D. Bayne.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without modification, are permitted provided that
  6.  * the following conditions are met:
  7.  *
  8.  * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
  9.  *    following disclaimer.
  10.  *
  11.  * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
  12.  *    following disclaimer in the documentation and/or other materials provided with the distribution.
  13.  *
  14.  * 3. All advertising materials mentioning features or use of this software must display the following
  15.  *    acknowledgement:
  16.  *
  17.  *       This product includes software developed by Michael D. Bayne.
  18.  *
  19.  * 4. My name may not be used to endorse or promote products derived from this software without specific prior
  20.  *    written permission.
  21.  *
  22.  * THIS SOFTWARE IS PROVIDED BY MICHAEL D. BAYNE ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
  23.  * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  24.  * IN NO EVENT SHALL MICHAEL D. BAYNE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  25.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  27.  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28.  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29.  */
  30.  
  31. #include <exec/tasks.h>
  32. #include <exec/execbase.h>
  33. #include <intuition/intuition.h>
  34. #include <intuition/intuitionbase.h>
  35. #include <dos/dos.h>
  36.  
  37. #include "TaskE.h"
  38. #include "defs.h"
  39.  
  40. extern    struct    ExecBase *SysBase;
  41. extern    struct    IntuitionBase *IBase;
  42. extern    struct    List *scrList;
  43.  
  44. void sendSigAbrt( struct TaskNode *t )
  45. {
  46.     APTR Lock;
  47.  
  48.     if( TaskExists( t->tn_TaskAddress )) Signal(( struct Task * )t->tn_TaskAddress, SIGBREAKF_CTRL_C );
  49.  
  50.     Lock = rtLockWindow( TaskEWnd );
  51.     Delay( 50 );
  52.     rtUnlockWindow( TaskEWnd, Lock );
  53. }
  54.  
  55. void popScreen( int item )
  56. {
  57.     struct    Screen    *Scr;
  58.         ULONG    lock, num;
  59.     struct    Node    *t;
  60.  
  61.     for( t = scrList->lh_Head, num = 0; num != item; num++, t = t->ln_Succ );
  62.  
  63.     lock = LockIBase( 0 );
  64.  
  65.     for( Scr = IBase->FirstScreen; Scr; Scr = Scr->NextScreen )
  66.         if(!( Strnicmp( Scr->DefaultTitle, t->ln_Name, 30 ))) break;
  67.     
  68.     UnlockIBase( lock );
  69.  
  70.     if( Scr ) {
  71.         ScreenToFront( Scr );
  72.         if( Scr->FirstWindow ) ActivateWindow( Scr->FirstWindow );
  73.     }
  74. }
  75.  
  76. LONG TaskExists( ULONG Addr )
  77. {
  78.     struct Node        *execNode;
  79.     int retval = 0;
  80.  
  81.         Disable();
  82.         
  83.     for( execNode = (SysBase->TaskWait).lh_Head; execNode; execNode = execNode->ln_Succ )
  84.         if( retval = ( Addr == (ULONG)execNode )) break;
  85.  
  86.     if( !retval )
  87.         for( execNode = (SysBase->TaskReady).lh_Head; execNode; execNode = execNode->ln_Succ )
  88.             retval = ( Addr == (ULONG)execNode );
  89.     Enable();
  90.     return( retval );
  91. }
  92.  
  93.